package com.laowang.project.system.controller;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.laowang.common.utils.SecurityUtils;
import com.laowang.framework.web.domain.PageObject;
import com.laowang.framework.web.page.TableDataInfoMy;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.TbAccountDetail;
import com.laowang.project.system.service.TbAccountDetailService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 账户详情Controller
 * 
 * @author laowang
 * @date 2022-12-29
 */
@Api(tags = "账户详情接口")
@RestController
@RequestMapping("/accountDetail")
public class TbAccountDetailController extends BaseController {


    @Autowired
    private TbAccountDetailService tbAccountDetailService;

    @ApiOperation(value = "小程序端 明细 ",notes = "")
    @PostMapping("/listDetail")
    public TableDataInfoMy listDetail(@RequestBody TbAccountDetail tbAccountDetail) {
        PageHelper.startPage(tbAccountDetail.getPageNum(),tbAccountDetail.getPageSize());
        Integer mid = SecurityUtils.getLoginUser().getWxUser().getMid();
        tbAccountDetail.setUserId(mid);
        List<TbAccountDetail> list = tbAccountDetailService.selectTbAccountDetailList(tbAccountDetail);
        return getDataTableMy(list);
    }


    /**
     * 查询账户详情列表
     */
    @ApiOperation(value = "查询账户详情列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:list')")
    @GetMapping("/list")
        public TableDataInfo list(TbAccountDetail tbAccountDetail) {
        startPage();
        List<TbAccountDetail> list = tbAccountDetailService.selectTbAccountDetailList(tbAccountDetail);
        return getDataTable(list);
    }
    
    /**
     * 导出账户详情列表
     */
    @ApiOperation(value = "导出账户详情列表",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:export')")
    @Log(title = "账户详情", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TbAccountDetail tbAccountDetail) {
        List<TbAccountDetail> list = tbAccountDetailService.selectTbAccountDetailList(tbAccountDetail);
        ExcelUtil<TbAccountDetail> util = new ExcelUtil<TbAccountDetail>(TbAccountDetail.class);
        return util.exportExcel(list, "accountDetail");
    }

    /**
     * 获取账户详情详细信息
     */
    @ApiOperation(value = "获取账户详情详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") String detailId) {
        return AjaxResult.success(tbAccountDetailService.selectTbAccountDetailById(detailId));
    }

    /**
     * 新增账户详情
     */
    @ApiOperation(value = "新增账户详情",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:add')")
    @Log(title = "账户详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbAccountDetail tbAccountDetail) {
        return toAjax(tbAccountDetailService.insertTbAccountDetail(tbAccountDetail));
    }

    /**
     * 修改账户详情
     */
    @ApiOperation(value = "修改账户详情",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:edit')")
    @Log(title = "账户详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbAccountDetail tbAccountDetail) {
        return toAjax(tbAccountDetailService.updateTbAccountDetail(tbAccountDetail));
    }

    /**
     * 删除账户详情
     */
    @ApiOperation(value = "删除账户详情",notes = "")
    @PreAuthorize("@ss.hasPermi('system:accountDetail:remove')")
    @Log(title = "账户详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable String[] detailIds) {
        return toAjax(tbAccountDetailService.deleteTbAccountDetailByIds(detailIds));
    }
}
